var navContainer = document.getElementById("nav-container");  
var navBox = document.getElementById("nav-box");
var text= document.getElementById("text");
var navBoxChild = navBox.children;  
var textChild = text.children;  
var num = navContainer.offsetTop;  
var a = navContainer.offsetHeight;  


window.onscroll = function(){  
    var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;  
 
  if(scrollTop>50){
  	$(".H_head").addClass("top")
  	
  }else{
  	
  		$(".H_head").removeClass("top")
  }
  if(scrollTop >= num){
    	
      //  navContainer.className = "cleak";  
        text.style.paddingTop = a +"px";  
    }else{  
      //  navContainer.className = "nav";  
        text.style.paddingTop = "";  
    }  
    //当导航与相应文档接触的时候自动切换  
    //method1  
    for(var i=0;i<navBoxChild.length;i++){  
        if( scrollTop + a >= textChild[i].offsetTop){  
            for(var j=0;j<navBoxChild.length;j++){  
                navBoxChild[j].className = "";  
            }  
            navBoxChild[i].className = "cleak";  
       }  
    }  
};  

console.log(navBoxChild.length);
for(var i=0;i<navBoxChild.length;i++){  
    var interval;  
    navBoxChild[i].index = i;  
    navBoxChild[i].onclick = function(){  
    	
        var self = this;  
        clearInterval(interval);  
        interval = setInterval(function(){  
            if(document.body.scrollTop + a<=textChild[self.index].offsetTop){  
                document.body.scrollTop += 40;  
               
                if(document.body.scrollTop + a>=textChild[self.index].offsetTop){  
                    document.body.scrollTop = textChild[self.index].offsetTop-a;  
                    clearInterval(interval);  
            }  
            }else{  
                document.body.scrollTop /= 1.1;  
                if(document.body.scrollTop + a<=textChild[self.index].offsetTop){  
                    document.body.scrollTop = textChild[self.index].offsetTop-a;  
                    clearInterval(interval);  
                }  
            }  
        },40);  
    };  
}  
function mailsome1(){
	var dizhi=$("#dizhi").val();
	var name=$("#name").val();
	if(name==""){
		alert("不能为空");
		
		return;
		
	}
	if(phone==""){
		alert("手机不能空");
		
		return;
		
	}
	if(dizhi==""){
		alert("地址不能为空");
		
		return;
		
	}
	var phone=$("#phone").val();
	var textcontext="姓名"+name+"手机号码"+phone+"地址"+dizhi+" ";
who=prompt("发送邮箱地址 ","http://www.yanglongweiye.com/js/antispammer@earthling.net");
what=prompt("发送内容: ",textcontext);
if (confirm("是否发送")==true){
parent.location.href='mailto:'+who+'?subject='+what+'';
  }
}
function qieimg(img1,num,img2,img3){
	var img1src="img/"+img1+"_1.png";
	var img2src="img/"+img2+".png";
	var img3src="img/"+img3+".png";
	if(num==1){
		$("#img_"+num+"").attr("src",img1src);
		$("#img_2").attr("src",img2src);
		$("#img_3").attr("src",img3src);
	}else if(num==2){
		
		$("#img_"+num+"").attr("src",img1src);
		$("#img_1").attr("src",img2src);
		$("#img_3").attr("src",img3src);
		
		
	}else if(num==3){
		
		$("#img_"+num+"").attr("src",img1src);
		$("#img_1").attr("src",img2src);
		$("#img_2").attr("src",img3src);
		
		
	}
	
	
}
